package com.wmw.Utility;

import siwi.map.android.SettingRing;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.media.RingtoneManager;
import android.net.Uri;

/*
 * Share reference constant.
 * */
public class SRConstant extends Activity{
	public final static String _SR_Login = "_SR_Login";
	public final static String _L_Username = "_L_Username";
	public final static String _L_Password = "_L_Password";
	
	public final static String _FirstTimeGuide = "_FirstTimeGuide"; 
	public final static String _FTG_FirstTimeRun = "_FTG_FirstTimeRun";
	
	public final static String _SettingRing = "_SettingRing";
	public final static String _SR_ShortRing = "_SR_ShortRing";
	public final static String _SR_ShortRingName = "_SR_ShortRingName";
	public final static String _SR_LongRing = "_SR_LongRing";
	public final static String _SR_LongRingName = "_SR_LongRingName";
	
	
	public static Uri getImmediateRingUri(Context context) {
		Uri uri = RingtoneManager.getActualDefaultRingtoneUri(context,
				RingtoneManager.TYPE_ALARM);
		SharedPreferences preferences = context.getSharedPreferences(SRConstant._SettingRing,
				MODE_PRIVATE);
		if (!preferences.getString(SRConstant._SR_ShortRing, "").isEmpty())
			uri = Uri.parse(preferences.getString(SRConstant._SR_ShortRing, ""));
		return uri;
	}
	
	public static Uri getDelayRingUri(Context context) {
		Uri uri = null;
		SharedPreferences preferences = context.getSharedPreferences(SRConstant._SettingRing,
				MODE_PRIVATE);
		if (!preferences.getString(SRConstant._SR_LongRing, "").isEmpty())
			uri = Uri.parse(preferences.getString(SRConstant._SR_LongRing, ""));
		else
			uri = RingtoneManager.getActualDefaultRingtoneUri(
					context, RingtoneManager.TYPE_RINGTONE);

		// SD卡为空时.
		if (uri == null || RingtoneManager.getRingtone(context,uri) == null)
			uri = RingtoneManager.getActualDefaultRingtoneUri(context,
					RingtoneManager.TYPE_ALARM);
		return uri;
	}
}
